namespace SimpleWebServices.Web.Routing
{
    using System;
    using System.Web.Routing;
    using SimpleWebServices;
    using SimpleWebServices.Web.Mvc;
    using Xunit;

    public sealed class RouteCollectionExtensionMethodsFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(typeof(RouteCollectionExtensionMethods).IsStatic());
        }

        [Fact]
        public void op_RegisterOfT_RouteCollection()
        {
            RouteCollection obj = new RouteCollection();

            obj.Register<NotFoundController>();

            Assert.Equal<string>("{*url}", (obj[0] as Route).Url);
        }

        [Fact]
        public void op_Register_RouteCollection_IEnumerableOfType()
        {
            RouteCollection obj = new RouteCollection();

            obj.Register(new Type[] { typeof(NotFoundController) });

            Assert.Equal<string>("{*url}", (obj[0] as Route).Url);
        }

        [Fact]
        public void op_Register_RouteCollection_IEnumerableOfTypeNull()
        {
            Assert.Throws<ArgumentNullException>(() => new RouteCollection().Register(null as Type[]));
        }

        [Fact]
        public void op_Register_RouteCollection_Type()
        {
            RouteCollection obj = new RouteCollection();

            obj.Register(typeof(RouteCollectionTestController));

            Assert.NotEqual<int>(0, obj.Count);
        }

        [Fact]
        public void op_Register_RouteCollection_TypeNull()
        {
            Assert.Throws<ArgumentNullException>(() => new RouteCollection().Register(null as Type));
        }

        [Fact]
        public void op_Register_RouteCollection_Type_bool()
        {
            RouteCollection obj = new RouteCollection();

            obj.Register(typeof(RouteCollectionTestController), false);

            Assert.NotEqual<int>(0, obj.Count);
        }

        [Fact]
        public void op_Register_RouteCollection_TypeNull_bool()
        {
            Assert.Throws<ArgumentNullException>(() => new RouteCollection().Register(null as Type, false));
        }

        [Fact]
        public void op_Register_RouteCollection_TypeNull_ResourceAttribute()
        {
            Assert.Throws<ArgumentNullException>(() => new RouteCollection().Register(null as Type, new ResourceAttribute()));
        }

        [Fact]
        public void op_Register_RouteCollection_Type_ResourceAttributeNull()
        {
            Assert.Throws<ArgumentNullException>(() => new RouteCollection().Register(typeof(NotFoundController), null as ResourceAttribute));
        }
    }
}